<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            //ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
	<div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <!--/span-->
                <!-- left menu ends -->
						<form style="margin-bottom:10px;" class="form-inline">
							<div class="form-group">
								<div class="input-group">
									<input type="text" name="start_date" class="date_keyword" value="{$start_date}" placeholder="开始日期">
									<span class="input-group-addon">
										<span class=" ace-icon fa fa-calendar"></span>
									</span>
								</div>
							</div>
							<div class="form-group">
								<div class="input-group">
									<input type="text" name="end_date" class="date_keyword" value="{$end_date}" placeholder="结束日期">
									<span class="input-group-addon">
										<span class="ace-icon fa fa-calendar"></span>
									</span>
								</div>
							</div>
							<div class="form-group">
								<select id="search-name" name="agent_id" style="width: 310px;">
									<option value="0">选择代理</option>
									<volist name="agent" id="vo">
									<option <if condition="$agent_id eq $key">selected</if> value="{$key}">{$vo}</option>
									</volist>
								</select>
							</div>
							<button type="submit" class="btn btn-primary">查询</button>

							<span style="display:inline-block;margin-left:10px; margin-top: 8px;">
								<span>申请提现总额:</span> <span class="text-primary">¥ {$WLog_data['total_money']}</span>,
								<span>待打款:</span> <span class="text-primary">¥ {$WLog_data['apply_money']}</span>,
								<span>已打款:</span> <span class="text-primary">¥ {$WLog_data['play_money']}</span>
							</span>
						</form>

						<div class="clearfix">
							<ul class="nav nav-tabs pull-left">
								<li class="<if condition="$status eq '' || $status eq 'withdrawing'">active</if>">
									<a onclick="searchBills('withdrawing')">待打款</a>
								</li>
								<li class="<if condition="$status eq 'paid'">active</if>">
									<a onclick="searchBills('paid')">已打款</a>
								</li>
							</ul>
						</div>

						<table class="table table-striped table-bordered table-hover responsive">
							<thead>
								<tr>
									<td>申请单</td>
									<td>代理</td>
									<td class="text-right">
										提现金额
									</td>
									<td>收款方式</td>
									<td>收款人</td>
									<td>收款帐号</td>
									<td class="text-center">
										提交时间
									</td>
									<td>
										状态
									</td>
									<if condition="$status eq '' || $status eq 'withdrawing'">
									<td>
										操作
									</td>
									</if>
								</tr>
							</thead>
							<tbody>
									<if condition="$count eq 0">
									<tr>
										<td class="text-center" colspan="100">没有记录</td>
									</tr>
									<else/>
									<volist name="data" id="vo">
									<tr>
										<td><a href="{:U('withdraw_viwe',['id'=>$vo['id']])}">{$vo.out_biz_no}</a></td>
										<td>{$vo.user}</td>
										<td>￥{$vo.amount}</td>
										<td>
											<if condition="$vo.account_type eq 1">
												<font color="#03A9F4">支付宝</font>
												<elseif condition="$vo.account_type eq 2"/>
												<font color="#0baf11">微信</font>
												<elseif condition="$vo.account_type eq 3"/>
												<font color="#FFC107">银行卡</font>
												</if>
										</td>
										<td>{$vo.realname}</td>
										<td>{$vo.alipay}</td>
										<td>{$vo.create_time}</td>
										<td>
										<if condition="$vo.status eq 1">
											<span class="hierarchy_default hierarchy_fine">已打款</span>
										<else/>
											<span class="hierarchy_default hierarchy_good">待打款</span>
										</if>
										</td>
										<if condition="$status eq '' || $status eq 'withdrawing'">
										<td data-apply-id="{$vo['id']}">
											<button class="btn btn-primary play_confirm">确认打款</button>
											&nbsp;&nbsp;&nbsp;
											<button class="btn cancel" data-apply-user="{$vo.user}" data-apply-date="{$vo.create_time}">取消申请</button>
										</td>
										</if>
									</tr>
									</volist>
									</if>
							</tbody>
						</table>

                                <!-- PAGE CONTENT ENDS -->
                    </div>
                </div>
            </div><!-- /.page-content -->
			{$page}
        </div>
    </div><!-- /.main-content -->
	<include file="Public/footer"/>
</div><!-- /.main-container -->
<include file="Public/footerjs"/>
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript">
	$(function () {
		$('.date_keyword').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
		$('.play_confirm').click(function(){
			var apply_id = $(this).parent().attr('data-apply-id');
			layer.open({
				title: "打款确认",
				content: '<div class="col-xs-12" style="line-height: 40px;text-align: right;"><span class="col-md-4">打款单号：</span><span class="col-md-8"><input class="play_orderid" type="txt" style="line-height: 24px;"></span></div>',
				yes: function(index, layero){
					var play_orderid = $.trim(layero.find('.play_orderid').val());
					if(play_orderid == ''){
						alert('打款单号不能为空');
						return false;
					}
					layer.close(index); 
					$.post("{:U('play_confirm')}",{'apply':apply_id,'play_orderid':play_orderid}, function(data){
						layer_open(data);
					},'json');
				}
			});
		});
		$('.cancel').click(function(){
			var apply_id = $(this).parent().attr('data-apply-id');
			var user = $(this).attr('data-apply-user');
			var apply_date = $(this).attr('data-apply-date');
			layer.open({
				title: "申请取消",
				content: '确认取消<span style="color:#03A9F4">【'+user+'】</span>&nbsp;于&nbsp;'+apply_date+'&nbsp;&nbsp;申请的订单？',
				yes: function(index, layero){
					layer.close(index); 
					$.post("{:U('apply_cancel')}",{'apply':apply_id}, function(data){
						layer_open(data);
					},'json');
				}
			});
		});
	});
	function searchBills(status) {
		var startime = $("input[name=start_date]").val();
        var endtime = $("input[name=end_date]").val();
		var search = $("#search-name").val();
		location.href = '{:U('channels_play')}?start_date='+startime+'&end_date='+endtime+'&agent_id='+search+'&status='+status;
	}
	
	function layer_open(data){
		layer.open({
			title: data.title,
			content: data.msg,
			yes: function(index, layero){
				layer.close(index); 
			}
		});
	}
</script>
</body>
</html>